/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.study.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Truong Anh Tuan
 */
public class DButil {

    public DButil() {
    }

    public static  Connection GetConnection() {
        Connection conn = null;
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            conn = DriverManager.getConnection("jdbc:odbc:Study");
        } catch (SQLException ex) {
            Logger.getLogger(DButil.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(DButil.class.getName()).log(Level.SEVERE, null, ex);
        }
        return conn;
    }

    public static  void closeConnection(Connection con) {
        try {
            if (!con.isClosed()) {
                con.close();
            }
        } catch (SQLException ex) {
            Logger.getLogger(DButil.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
